Skip to content

fix(llm): stream chunks as they arrive and raise stream errors at the call - #320

Open
1qh wants to merge 1 commit into
lfnovo:mainfrom
1qh:fix/stream-incremental
Open

1qh wants to merge 1 commit into
lfnovo:mainfrom
1qh:fix/stream-incremental

Conversation

@1qh

@1qh 1qh commented Oct 26, 2026

Copy link
Copy Markdown

Problem

With stream=True, every HTTP-based LLM provider sends the request with a buffered client.post(...) / async_client.post(...) and then parses the SSE events from the finished response. httpx reads the whole body before post returns, so the "stream" arrives all at once when the model has finished.

Measured against an OpenAI-compatible vLLM gateway with OpenAICompatibleLanguageModel.achat_complete(stream=True):

1st chunk total
2.28.0 6.72 s 6.73 s
raw httpx stream to the same server 0.53 s 2.09 s
this branch 0.50-0.56 s 3.8 s

Azure already used client.stream(...), but raised HTTP errors inside the generator, so a 429 surfaced only when the caller started iterating.

Change

  • LanguageModel._open_stream / _aopen_stream (base class): build the request, send(..., stream=True), and on an error status read the body, close it and call the provider's _handle_error, so the error is raised at the call, before an iterator is returned. A caller that retries on 429 (or any rate limit) therefore still sees it where it can retry.
  • Every provider whose streaming path parsed a buffered response now uses the helpers and closes the response in a finally: anthropic, azure, cohere, google, groq, mistral, ollama (NDJSON), openai, openai_compatible (and the profiles that inherit it), openrouter, perplexity.
  • Vertex is unchanged: its REST path calls the non-streaming generateContent and yields 1 chunk by design.

Tests

  • tests/providers/llm/test_streaming_transport.py: for each of the 11 classes, sync and async, chat_complete(stream=True) against an httpx.MockTransport whose body sends the 1st event and then blocks until the test has received the 1st chunk. Buffered code can never return that chunk, so the test times out. Proven by reverting Groq to the buffered .post: test_provider_chat_streaming_opens_before_body_finishes[GroqLanguageModel] timed out; restored, the file passes.
  • A 429 matrix: the error is raised by the chat_complete/achat_complete call itself, before iteration.
  • The existing streaming tests that mocked .post now mock the opening path; every assertion on payloads (stream flag, merged extra_body, tools, thinking) and on chunk content is kept.

uv run pytest tests/providers tests/unit tests/common_types tests/test_deprecation_warnings.py -q --no-cov: 1792 passed (1748 on main), ruff check . and mypy src/esperanto clean.

… call

Every streaming provider sent the request with a buffered post, which reads the
whole response body before the first chunk is yielded, so a stream arrived all at
once at the end. Streams now open with send(stream=True) through shared base-class
helpers; an error status is read and raised before the iterator is returned, so a
caller that retries on 429 sees it at the call. Covers anthropic, azure, cohere,
google, groq, mistral, ollama, openai, openai_compatible, openrouter, perplexity.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21 issues found across 22 files

Confidence score: 3/5

  • In the SSE parsers in groq.py, perplexity.py, cohere.py, mistral.py, anthropic.py, openrouter.py, and google.py, a data: line split across network reads can be silently dropped, losing streamed content or tool-call deltas. Buffer incomplete lines before parsing.
  • In azure.py, a response can stay open if the returned stream is never iterated, because cleanup only runs in the generator’s finally. Close the response when the stream is abandoned.
  • The streaming tests in test_cohere.py and test_openai_provider.py can pass without verifying the new streaming request path or payload. Assert that requests use send(..., stream=True) and include "stream": true where applicable.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/esperanto/providers/llm/groq.py">

<violation number="1" location="src/esperanto/providers/llm/groq.py:369">
P2: The returned generator closes the streaming response only inside its `try/finally`, which doesn't run until iteration starts. A caller that discards the generator unread keeps the connection open until garbage collection. Consider closing the response eagerly on that path, or accept this as an acceptable tradeoff and document it.</violation>

<violation number="2" location="src/esperanto/providers/llm/groq.py:376">
P1: Streaming now reads the live socket, but `_parse_sse_stream` still splits each `iter_text()` chunk on newlines. A network read that ends mid-event makes `json.loads` fail, and the event is silently dropped. Buffer partial lines across chunks (or switch to `response.iter_lines()` as Ollama does) before parsing, in both sync and async parsers.</violation>
</file>

<file name="src/esperanto/providers/llm/azure.py">

<violation number="1" location="src/esperanto/providers/llm/azure.py:431">
P2: The response is now opened before the generator exists, but it is only closed inside the generator's `finally`. If the returned stream is dropped without ever being iterated, `finally` never runs and the connection stays checked out. Tie the close to the generator object's lifetime, for example with `weakref.finalize`, so an unstarted stream still releases its response.</violation>
</file>

<file name="tests/providers/llm/test_cohere.py">

<violation number="1" location="tests/providers/llm/test_cohere.py:87">
P2: These mocks do not make the streaming tests exercise the new streaming request path: the existing `post` mocks remain fully usable, and the tests never assert `send(..., stream=True)`. Add sync and async assertions for the `send` calls so a regression to buffered `post` cannot pass.</violation>
</file>

<file name="tests/providers/llm/test_openai_provider.py">

<violation number="1" location="tests/providers/llm/test_openai_provider.py:351">
P2: The async streaming test does not verify the request payload contains `"stream": true`; its `send` mock ignores the request body, so a regression in the provider payload can pass while the API stops streaming. Assert the serialized request body includes the streaming field, as the synchronous test already does.</violation>
</file>

<file name="tests/providers/llm/test_openai_compatible_provider.py">

<violation number="1" location="tests/providers/llm/test_openai_compatible_provider.py:717">
P2: This streaming test configures the synchronous response's `aclose`, but the provider closes it with `close()` and the test never asserts cleanup. Configure and assert `mock_resp.close` after exhausting the generator, and assert `mock_resp.aclose` in the async test so response-leak regressions fail.</violation>
</file>

<file name="src/esperanto/providers/llm/perplexity.py">

<violation number="1" location="src/esperanto/providers/llm/perplexity.py:409">
P1: The stream parser now receives real network chunks, but it splits each `iter_text()` chunk on newlines without buffering partial lines. An SSE `data:` event split across two reads fails `json.loads` and is silently dropped, losing streamed content or tool-call deltas. Buffer the text and only parse complete lines, carrying the remainder into the next chunk, in `_parse_sse_stream` and `_parse_sse_stream_async`.</violation>
</file>

<file name="tests/providers/llm/test_anthropic_provider.py">

<violation number="1" location="tests/providers/llm/test_anthropic_provider.py:440">
P2: This mock makes `build_request` asynchronous even though `_aopen_stream` calls it synchronously, producing an unawaited coroutine and leaving request construction untested. Replace the child with a regular `Mock` so the side effect executes when the provider builds the request.</violation>
</file>

<file name="src/esperanto/providers/llm/ollama.py">

<violation number="1" location="src/esperanto/providers/llm/ollama.py:361">
P2: The stream is opened eagerly, but the only `close()` is inside the generator body. If the returned generator is never iterated, its `finally` never runs, so the response and its pooled connection stay checked out. Attach cleanup to the generator object's lifetime (for example `weakref.finalize(gen, response.close)`), and do the same for the async branch with `aclose`.</violation>
</file>

<file name="src/esperanto/providers/llm/cohere.py">

<violation number="1" location="src/esperanto/providers/llm/cohere.py:594">
P1: Streaming now reads raw network chunks, but `_parse_sse_stream` splits each chunk on newlines independently. An SSE `data:` line that spans two reads is parsed as two broken fragments, both are silently skipped, and those tokens are lost. Buffer partial lines across reads, for example by iterating `response.iter_lines()` in `_parse_sse_stream` and `_parse_sse_stream_async`. The other HTTP providers share this parser pattern and need the same change.</violation>
</file>

<file name="src/esperanto/providers/llm/mistral.py">

<violation number="1" location="src/esperanto/providers/llm/mistral.py:381">
P2: The response is opened eagerly, but it is closed only inside the generator body. If the returned generator is discarded before the first `next()`, the `finally` never runs and the connection leaks. Consider closing the response when the generator is discarded, or opening the stream lazily once the first chunk is requested.</violation>

<violation number="2" location="src/esperanto/providers/llm/mistral.py:385">
P1: Streaming now reads the body incrementally, but `_parse_sse_stream` splits each `iter_text()` chunk on newlines independently. An SSE event split across two network reads is silently dropped, so content goes missing mid-stream. Buffer partial lines across chunks, e.g. by iterating `response.iter_lines()`.</violation>
</file>

<file name="src/esperanto/providers/llm/anthropic.py">

<violation number="1" location="src/esperanto/providers/llm/anthropic.py:778">
P2: Opening the response before returning the generator leaves it unclosed when callers abandon the stream before its first `next()`/`anext()`; the generator’s `finally` never starts. Return a stream wrapper with deterministic cleanup (including an unstarted stream), or otherwise document and enforce cleanup for abandoned streams.</violation>

<violation number="2" location="src/esperanto/providers/llm/anthropic.py:783">
P1: The new streaming path feeds `_parse_sse_stream` raw network chunks, but that parser assumes each chunk holds complete lines. A chunk boundary inside a `data:` line silently drops that event, so text or tool-call deltas go missing with no error. Buffer partial lines across chunks in `_parse_sse_stream` and `_parse_sse_stream_async`, and flush the remainder at end of stream. The same applies to the async call on the `_parse_sse_stream_async` line.</violation>
</file>

<file name="src/esperanto/providers/llm/openrouter.py">

<violation number="1" location="src/esperanto/providers/llm/openrouter.py:274">
P2: The returned stream never closes the response if the caller discards it without iterating. The `finally` only runs after the generator has started, so the connection stays checked out of the httpx pool. Consider closing the response when the iterator is garbage-collected or documenting that callers must consume or close the stream. The async `generate()` has the same gap.</violation>

<violation number="2" location="src/esperanto/providers/llm/openrouter.py:278">
P1: Streaming now reads the body incrementally, but `_parse_sse_stream` splits each `iter_text()` piece on newlines without buffering partial lines. An SSE `data:` event split across reads is dropped silently by the JSON decode fallback, so chunks can go missing. The parser needs a line buffer that carries the incomplete tail into the next piece. This is the inherited parser, so the fix belongs in openai.py, but this OpenRouter path depends on it.</violation>
</file>

<file name="src/esperanto/providers/llm/google.py">

<violation number="1" location="src/esperanto/providers/llm/google.py:503">
P2: The stream is opened before `generate()` is returned, but it is only closed inside the generator's `try/finally`. If the caller never starts iterating, the connection is never released. Consider returning an iterator object that owns `response` and closes it in `close()` or `__del__`, so unconsumed streams are released. The async path has the same gap.</violation>

<violation number="2" location="src/esperanto/providers/llm/google.py:506">
P2: The SSE parser splits each network chunk on `\n` and silently drops any line whose JSON is incomplete. Now that the body streams, an event split across chunk boundaries is lost without an error. Buffer partial lines across chunks, e.g. iterate `response.iter_lines()` / `aiter_lines()` as `ollama.py` does.</violation>
</file>

<file name="src/esperanto/providers/llm/openai_compatible.py">

<violation number="1" location="src/esperanto/providers/llm/openai_compatible.py:376">
P2: The streaming response is opened before the generator starts, so an iterator that is never consumed never closes it. Close the response on the abandon path too, for example with a `weakref.finalize(gen, response.close)` registration or a small iterator wrapper with `__del__`.</violation>
</file>

<file name="CHANGELOG.md">

<violation number="1" location="CHANGELOG.md:13">
P3: Document this new streaming contract in the README and LLM capability guide. Their streaming sections omit both early chunk delivery and the fact that HTTP errors surface before iteration.</violation>
</file>

<file name="src/esperanto/providers/llm/base.py">

<violation number="1" location="src/esperanto/providers/llm/base.py:109">
P2: A failed read of an error response skips `close()`, leaking the streamed response. Wrap both `read()`/`aread()` calls in `try/finally` blocks so `close()`/`aclose()` always runs.</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

try:
yield from (
self._normalize_chunk(chunk_data)
for chunk_data in self._parse_sse_stream(response)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Streaming now reads the live socket, but _parse_sse_stream still splits each iter_text() chunk on newlines. A network read that ends mid-event makes json.loads fail, and the event is silently dropped. Buffer partial lines across chunks (or switch to response.iter_lines() as Ollama does) before parsing, in both sync and async parsers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/groq.py, line 376:

<comment>Streaming now reads the live socket, but `_parse_sse_stream` still splits each `iter_text()` chunk on newlines. A network read that ends mid-event makes `json.loads` fail, and the event is silently dropped. Buffer partial lines across chunks (or switch to `response.iter_lines()` as Ollama does) before parsing, in both sync and async parsers.</comment>

<file context>
@@ -365,17 +365,27 @@ def chat_complete(
+                try:
+                    yield from (
+                        self._normalize_chunk(chunk_data)
+                        for chunk_data in self._parse_sse_stream(response)
+                    )
+                finally:
</file context>

)
def generate():
try:
yield from (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The stream parser now receives real network chunks, but it splits each iter_text() chunk on newlines without buffering partial lines. An SSE data: event split across two reads fails json.loads and is silently dropped, losing streamed content or tool-call deltas. Buffer the text and only parse complete lines, carrying the remainder into the next chunk, in _parse_sse_stream and _parse_sse_stream_async.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/perplexity.py, line 409:

<comment>The stream parser now receives real network chunks, but it splits each `iter_text()` chunk on newlines without buffering partial lines. An SSE `data:` event split across two reads fails `json.loads` and is silently dropped, losing streamed content or tool-call deltas. Buffer the text and only parse complete lines, carrying the remainder into the next chunk, in `_parse_sse_stream` and `_parse_sse_stream_async`.</comment>

<file context>
@@ -400,17 +400,27 @@ def chat_complete(
+            )
+            def generate():
+                try:
+                    yield from (
+                        self._normalize_chunk(chunk_data)
+                        for chunk_data in self._parse_sse_stream(response)
</file context>

)
def generate():
try:
for event_data in self._parse_sse_stream(response):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Streaming now reads raw network chunks, but _parse_sse_stream splits each chunk on newlines independently. An SSE data: line that spans two reads is parsed as two broken fragments, both are silently skipped, and those tokens are lost. Buffer partial lines across reads, for example by iterating response.iter_lines() in _parse_sse_stream and _parse_sse_stream_async. The other HTTP providers share this parser pattern and need the same change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/cohere.py, line 594:

<comment>Streaming now reads raw network chunks, but `_parse_sse_stream` splits each chunk on newlines independently. An SSE `data:` line that spans two reads is parsed as two broken fragments, both are silently skipped, and those tokens are lost. Buffer partial lines across reads, for example by iterating `response.iter_lines()` in `_parse_sse_stream` and `_parse_sse_stream_async`. The other HTTP providers share this parser pattern and need the same change.</comment>

<file context>
@@ -585,21 +585,27 @@ def chat_complete(
+            )
+            def generate():
+                try:
+                    for event_data in self._parse_sse_stream(response):
+                        chunk = self._normalize_stream_event(event_data)
+                        if chunk:
</file context>

try:
yield from (
self._normalize_chunk(chunk_data)
for chunk_data in self._parse_sse_stream(response)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Streaming now reads the body incrementally, but _parse_sse_stream splits each iter_text() chunk on newlines independently. An SSE event split across two network reads is silently dropped, so content goes missing mid-stream. Buffer partial lines across chunks, e.g. by iterating response.iter_lines().

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/mistral.py, line 385:

<comment>Streaming now reads the body incrementally, but `_parse_sse_stream` splits each `iter_text()` chunk on newlines independently. An SSE event split across two network reads is silently dropped, so content goes missing mid-stream. Buffer partial lines across chunks, e.g. by iterating `response.iter_lines()`.</comment>

<file context>
@@ -374,17 +374,27 @@ def chat_complete(
+                try:
+                    yield from (
+                        self._normalize_chunk(chunk_data)
+                        for chunk_data in self._parse_sse_stream(response)
+                    )
+                finally:
</file context>

)
def generate():
try:
for event_data in self._parse_sse_stream(response):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The new streaming path feeds _parse_sse_stream raw network chunks, but that parser assumes each chunk holds complete lines. A chunk boundary inside a data: line silently drops that event, so text or tool-call deltas go missing with no error. Buffer partial lines across chunks in _parse_sse_stream and _parse_sse_stream_async, and flush the remainder at end of stream. The same applies to the async call on the _parse_sse_stream_async line.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/anthropic.py, line 783:

<comment>The new streaming path feeds `_parse_sse_stream` raw network chunks, but that parser assumes each chunk holds complete lines. A chunk boundary inside a `data:` line silently drops that event, so text or tool-call deltas go missing with no error. Buffer partial lines across chunks in `_parse_sse_stream` and `_parse_sse_stream_async`, and flush the remainder at end of stream. The same applies to the async call on the `_parse_sse_stream_async` line.</comment>

<file context>
@@ -774,22 +774,27 @@ def chat_complete(
+            )
+            def generate():
+                try:
+                    for event_data in self._parse_sse_stream(response):
+                        chunk = self._normalize_stream_event(event_data)
+                        if chunk:
</file context>

if chunk: # Only yield if chunk is not None
yield chunk
try:
for chunk_data in self._parse_sse_stream(response):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The SSE parser splits each network chunk on \n and silently drops any line whose JSON is incomplete. Now that the body streams, an event split across chunk boundaries is lost without an error. Buffer partial lines across chunks, e.g. iterate response.iter_lines() / aiter_lines() as ollama.py does.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/google.py, line 506:

<comment>The SSE parser splits each network chunk on `\n` and silently drops any line whose JSON is incomplete. Now that the body streams, an event split across chunk boundaries is lost without an error. Buffer partial lines across chunks, e.g. iterate `response.iter_lines()` / `aiter_lines()` as `ollama.py` does.</comment>

<file context>
@@ -499,22 +499,21 @@ def chat_complete(
-                    if chunk:  # Only yield if chunk is not None
-                        yield chunk
+                try:
+                    for chunk_data in self._parse_sse_stream(response):
+                        chunk = self._normalize_chunk(chunk_data)
+                        if chunk:  # Only yield if chunk is not None
</file context>

payload.update(self._strip_reserved_extras(merged_extra_body))

if should_stream:
response = self._open_stream(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The streaming response is opened before the generator starts, so an iterator that is never consumed never closes it. Close the response on the abandon path too, for example with a weakref.finalize(gen, response.close) registration or a small iterator wrapper with __del__.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/openai_compatible.py, line 376:

<comment>The streaming response is opened before the generator starts, so an iterator that is never consumed never closes it. Close the response on the abandon path too, for example with a `weakref.finalize(gen, response.close)` registration or a small iterator wrapper with `__del__`.</comment>

<file context>
@@ -372,19 +372,27 @@ def _make_chat_request(
         payload.update(self._strip_reserved_extras(merged_extra_body))
 
+        if should_stream:
+            response = self._open_stream(
+                f"{self.base_url}/chat/completions", self._get_headers(), payload
+            )
</file context>


# Make HTTP request
if should_stream:
response = self._open_stream(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Opening the response before returning the generator leaves it unclosed when callers abandon the stream before its first next()/anext(); the generator’s finally never starts. Return a stream wrapper with deterministic cleanup (including an unstarted stream), or otherwise document and enforce cleanup for abandoned streams.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/anthropic.py, line 778:

<comment>Opening the response before returning the generator leaves it unclosed when callers abandon the stream before its first `next()`/`anext()`; the generator’s `finally` never starts. Return a stream wrapper with deterministic cleanup (including an unstarted stream), or otherwise document and enforce cleanup for abandoned streams.</comment>

<file context>
@@ -774,22 +774,27 @@ def chat_complete(
 
-        # Make HTTP request
+        if should_stream:
+            response = self._open_stream(
+                f"{self.base_url}/messages", self._get_headers(), payload
+            )
</file context>

request = self.client.build_request("POST", url, headers=headers, json=payload)
response = self.client.send(request, stream=True)
if response.status_code >= 400:
response.read()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: A failed read of an error response skips close(), leaking the streamed response. Wrap both read()/aread() calls in try/finally blocks so close()/aclose() always runs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/esperanto/providers/llm/base.py, line 109:

<comment>A failed read of an error response skips `close()`, leaking the streamed response. Wrap both `read()`/`aread()` calls in `try/finally` blocks so `close()`/`aclose()` always runs.</comment>

<file context>
@@ -90,6 +92,40 @@ def _clean_config(self, config: Dict[str, Any]) -> Dict[str, Any]:
+        request = self.client.build_request("POST", url, headers=headers, json=payload)
+        response = self.client.send(request, stream=True)
+        if response.status_code >= 400:
+            response.read()
+            response.close()
+            self._handle_error(response)
</file context>

Comment thread CHANGELOG.md
### Fixed

- **LLM streaming now yields chunks as they arrive.** Errors on a streamed call are
raised when the call is made, before iteration begins.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Document this new streaming contract in the README and LLM capability guide. Their streaming sections omit both early chunk delivery and the fact that HTTP errors surface before iteration.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At CHANGELOG.md, line 13:

<comment>Document this new streaming contract in the README and LLM capability guide. Their streaming sections omit both early chunk delivery and the fact that HTTP errors surface before iteration.</comment>

<file context>
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
+### Fixed
+
+- **LLM streaming now yields chunks as they arrive.** Errors on a streamed call are
+  raised when the call is made, before iteration begins.
+
 ## [2.28.0] - 2026-10-03
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant